<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>短信项目修改</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet"
	type="text/css">
<link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
<link href="../../css/style.css" rel="stylesheet" type="text/css">
<script src="../../layui/layui.js"></script>
<script src="../../js/jquery-1.8.3.js"></script>
<script src="../../js/util.js"></script>

<script>
	layui.use([ 'form', 'jquery', 'element', 'laydate', 'layer', 'upload' , 'table' ], function() {
		var table = layui.table;
		var form = layui.form;
		var $ = layui.$;
		var laydate = layui.laydate;
		var layer = layui.layer;
		var upload = layui.upload;
		var mgrId = getUrlParam("mgrId");
		var cityId = getUrlParam("cityId");
		var step = 1;//用于下一步操作展示隐藏div
		var copyMgrId="";//被复制项目的Id
		var importStationType="";//导入基站csv文件类型（追加or覆盖）
		var options = {
                elem: "#table",//表格id
                id: "modelReload", //id
                url: '/smsBaseStation/find',
                method: 'post',
                request: {
                    pageName: 'page',
                    limitName: 'limit'
                },
                response: {
                    statusName: 'code',
                    statusCode: 0,
                    msgName: 'msg',
                    countName: 'count',
                    dataName: 'data'
                },
                page: true,
                count: "count",
                limit: 10,
                limits: [10, 20, 30, 40, 50],
                layout: ['prev', 'page', 'next'],
                prev: "上一页",
                next: "下一页",
                cols: [[ //表头
                     {field: 'regionId', title: '区域编码'}
                    , {field: 'regionName', title: '区域名称'}
                    , {field: 'stationId', title: '基站编码'}
                    , {field: 'stationName', title: '基站名称'}
                ]]
            };
            table.render(options);
		laydate.render({
	             elem: '#startTime'
	             , type: 'datetime'
	             ,min:minDate()
	        });
	    laydate.render({
	             elem: '#endTime'
	             , type: 'datetime'
	             ,min:minDate()
	        });    
	    function minDate(){
			    var now = new Date();
			    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
		}
		//判断是覆盖导入还是追加导入
		$(".importStation").click(function(){
			importStationType = $(this).attr('id');
		});
		upload.render({
			elem : '#importAdd,#importCover',
			url : '/template2/modifyByImport',
			auto : false, //关闭自动上传
			accept : 'file', //普通文件
			exts : 'csv', //只允许上传csv文件 //,multiple: true
			bindAction : '#upload2',
			before : function() {
				var startTime=$("#startTime").val();
		        var endTime=$("#endTime").val();
		        var everyDayStartTime=$("#everyDayStartTime").val();
		        var everyDayEndTime=$("#everyDayEndTime").val();
		        var realTime=$("input[name='realTime']:checked").val();
		        var isLocal=$("input[name='isLocal']:checked").val();
		        var isThreshold = 0;
	            $("input:checkbox[name='isThreshold']:checked").each(function () {
	                isThreshold += parseInt($(this).val());
	            });
	            var threshold = $("#threshold").val();
	            var cycleThreshold=0;
	            var cycle;
	            if(isThreshold==2||isThreshold==3){
	               	//cycle=$("#cycle").val();
	               	cycle = $("input[name='cycle']:checked").val();
	                cycleThreshold=$("#cycleThreshold").val();
	            }
	            var content=$("#content").val();
	            var localDate = 0;
	            var isProvince = 0;
	            if(isLocal==1){
	            	isProvince=$("#province").val();
	            }else if(isLocal==2){
	            	isProvince=1;
	            	localDate=$("input[name='localDate']:checked").val();
	            }else if(isLocal==0){
	             	localDate=$("input[name='localDate']:checked").val();
	            }
	            var param = {
	            		mgrId: mgrId,
	                    startTime: startTime,
	                    endTime: endTime,   
	                    everyDayStartTime: everyDayStartTime,
	                    everyDayEndTime: everyDayEndTime,
	                    realTime: realTime,
	                    isLocal: isLocal,
	                    isThreshold:isThreshold,
	                    threshold:threshold,
	                    cycleThreshold:cycleThreshold,
	                    cycle:cycle,
	                    newContent:content,
	                    localDate: localDate,
	                    isProvince: isProvince,
	                    effectTime:startTime,
	                    reset:"0",
	                    flag: "modify",
	                    cityId: cityId,
	                    importType:importStationType
	                };
	                var json = JSON.stringify(param);
	                alert(json);
						if (isNull(startTime)) {
				          layer.msg("发送开始时间不能为空");
				          return false;
				        }
				        if (isNull(everyDayStartTime)) {
				          layer.msg("每日发送开始时间不能为空");
				          return false;
				        }
				        if (isNull(everyDayEndTime)) {
				          layer.msg("每日发送结束时间不能为空");
				          return false;
				        }
				        if (isNull(realTime)) {
				          layer.msg("发送实时性不能为空");
				          return false;
				        }
				        if (isNull(isLocal)) {
				          layer.msg("号码发送范围不能为空");
				          return false;
				        }
				        if (isNull(content)) {
				          layer.msg("短信内容不能为空");
				          return false;
				        }
				        if (""!=endTime && null!=endTime && startTime>=endTime) {
			              layer.msg("发送结束时间不能小于等于开始时间");
			              return false;
			            }
			            if (everyDayStartTime>=everyDayEndTime) {
			              layer.msg("每日发送结束时间不能小于等于每日开始时间");
			              return false;
			            }
				layer.load(); //上传loading
				this.data = param;
			},
			done : function(obj) {

				layer.closeAll('loading'); //关闭loading
				if (obj.code == 0) {
					var data = obj.data;
					var num = data.toString().split(",");
					layer.confirm('模板添加成功，并成功导入' + data[0] + '个区域,' + data[1] + '个基站', {
						btn: ['确定'] //按钮
					}, function () {
						location.href="smsTemplateManage2.html";
					});
				}
				if (obj.code > 0) {
					layer.msg(obj.msg);
				}

			},
			error : function(index, upload) {
				layer.closeAll('loading'); //关闭loading
				layer.msg("上传过程中出现异常，请重试");
			}
		});
		laydate.render({
			elem : '#startTime',
			type : 'datetime'
		});
		laydate.render({
			elem : '#endTime',
			type : 'datetime'
		});

		laydate.render({
			elem : '#thresholdStartTime'
		});
		laydate.render({
			elem : '#thresholdEndTime'
		});
		laydate.render({
			elem : '#everyDayStartTime',
			type : 'time',
			value : '08:00:00',
			btns : [ 'clear', 'confirm' ]
		});
		laydate.render({
			elem : '#everyDayEndTime',
			type : 'time',
			value : '20:00:00',
			btns : [ 'clear', 'confirm' ]
		});


		function submit(parm) {
			layer.confirm('确认模板信息无误吗？是否需要再次查看', {
				btn : [ '不需要', '需要' ] //按钮
			}, function() {
				$.ajax({
					type : 'post',
					data : parm,
					url : "/template2/configure",
					beforeSend : function() {
						loading = layer.load(0, {
							shade : false
						});
					},
					success : function(json) {
						console.info(json);
						layer.close(loading);
						if (json.code == 0) {
							mgrId = json.data;
						} else {
							layer.msg(json.msg);
						}
					},
					complete : function() {},
					error : function(data) {
						layer.msg('系统异常，请联系管理员处理!');
					}
				});
			});
			return mgrId;
		}

		form.on('radio(localDate1)', function(data) {
			if (data.value == 0 || data.value == 2) {
				console.info(data.value);
				$("#province").hide();
				$("#local").show();
			} else if(data.value == 1){
				console.info(data.value);
				$("#local").hide();
				$("#province").show();
			}
		});

		/* function su() {
				var thresholdStartTime = $("#thresholdStartTime").val(); //时间范围内的开始时间
				var thresholdEndTime = $("#thresholdEndTime").val(); //时间范围内的结束时间
				var cycle = $("input[name='cycle']:checked").val(); //发送周期
				//阀值的形式
				var isThreshold = 0;
				$("input:checkbox[name='isThreshold']:checked").each(function() {
					isThreshold += parseInt($(this).val());
				});
				var name = $("#name").val();
				var cityId = $("#cityId").val();
				//var extId=$("#extId").val();
				var mgrId;
				var content = $("#content").val();
				var parm = {
					name : name,
					cityId : cityId,
					//extId: extId,
					//mgrId: mgrId,
					content : content,
					startTime : $("#startTime").val(), //项目开始时间
					endTime : $("#endTime").val(), //结束时间
					everyDayStartTime : $("#everyDayStartTime").val(), //每天发送的开始时间
					everyDayEndTime : $("#everyDayEndTime").val(), //每天发送的结束时间
					isLocal : $("input[name='isLocal']:checked").val(), //是否本地发送
					realTime : $("input[name='realTime']:checked").val(), //延时
					threshold : $("#threshold").val(), //全部阀值
					cycle : cycle, //发送周期
					cycleThreshold : $("#cycleThreshold").val(), //周期阀值
					thresholdStartTime : thresholdStartTime, //时间范围内的开始时间
					thresholdEndTime : thresholdEndTime, //时间范围内的结束时间
					isThreshold : isThreshold,
					flag : "insert",
					localDate : $("input[name='localDate']:checked").val() //本地发送保存时间
				};
				if (isNull(name)) {
					layer.msg("项目名称不能为空") ;
					return false;
				}
				if (isNull(cityId)) {
					layer.msg("必须选择一个城市");
					return false;
				}
				//     			if (isNull(extId)) {
				//     				layer.msg("必须选择一个扩展码");
				//     				return false;
				//     			}
				if ($("#everyDayStartTime").val() == null || $("#everyDayStartTime").val() == "") {
					layer.msg("每日发送开始时间不能为空");
					return false;
				}
				if ($("#everyDayEndTime").val() == null || $("#everyDayEndTime").val() == "") {
					layer.msg("每日发送结束时间不能为空");
					return false;
				}
				if ($("#everyDayStartTime").val() == null || $("#everyDayStartTime").val() == "") {
					layer.msg("每日发送开始时间不能为空");
					return false;
				}
				if ($("#everyDayEndTime").val() < $("#everyDayStartTime").val() || $("#everyDayEndTime").val() == $("#everyDayStartTime").val()) {
					layer.msg("每日发送结束时间要晚于开始时间");
					return false;
				}

				if (cycle == 5) {
					if (isNull(thresholdStartTime) || isNull(thresholdEndTime)) {
						layer.msg("请选择周期阀值的时间");
						return false;
					}
				}
				if (!checkRate($("#threshold").val())) {
					layer.msg("阀值必须为数字");
					return false;
				}
				if (!checkRate($("#cycleThreshold").val())) {
					layer.msg("阀值必须为数字");
					return false;
				}
				if ($("#startTime").val() == null || $("#startTime").val() == "") {
					layer.msg("发送开始时间不能为空");
					return false;
				}
				if (isThreshold < 2 && $("#cycleThreshold").val() > 0) {
					layer.confirm('短信周期发送量大于0，但并未勾选\'周期短信发送量\',按周期设置阀值不会生效,您是否要继续？', {
						btn : [ '继续', '取消' ] //按钮
					}, function() {
						mgrId = submit(parm);
					});
					return false;
				}
				if (isThreshold != 1 && isThreshold != 3 && $("#threshold").val() > 0) {
					layer.confirm('短信发送总条数大于0，但并未勾选\'短信发送总量\',总量阀值设置不会生效,您是否要继续？', {
						btn : [ '继续', '取消' ] //按钮
					}, function() {
						mgrId = submit(parm);
					});
					return false;
				} else {
					mgrId = submit(parm);
				}
				return mgrId;
			} */
		//监听项目
		/* form.on('select(cityId)', function(data) {
			var data = selectExtInfo(data.value);

			appendExtId(data);
		}); */
		//根据城市ID查询扩展码
		function selectExtInfo(cityId) {
			var data;
			var url = '/util/findExdId?cityId=' + cityId;
			$.ajax({
				type : 'post',
				async : false,
				url : url,
				success : function(json) {
					console.log(json.data);
					data = json.data;
				},
				error : function() {
					layer.msg('系统异常，请联系管理员处理!');
				}
			}
			);
			return data;
		}
		//动态拼接扩展码
		function appendExtId(data) {
			if (data.length != null) {
				var options = '<option value="">请选择</option>';
				for (var i = 0; i < data.length; i++) {
					options += '<option value="' + data[i] + '">' + data[i] + '</option>';
				}
				$('#extId').html(options);
			} else {
				//$('#extId').html('<option value="">该地市下没有扩展码</option>');
			}
			form.render();
		}
		//监听第三步中的地市、区县、项目
		//监听区县
            form.on('select(cityId_third)', function (data) {
                var data2 = selectCountyId(data.value);
                appendCountyThird(data2);
                var data1 = selectMgrInfo(data.value);
                appendMgrThird(data1);
            });
			
			 //监听项目
            form.on('select(countyId_third)', function (data) {
                var data1 = selectMgrInfo(data.value);
                appendMgrThird(data1);
            });
            //动态拼接区县
            function appendCountyThird(data){
                if (data.length != null) {
                    var options = '<option value="">请先选择地市</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                    }
                    $('#countyId_third').html(options);
                } else {
                    $('#countyId_third').html('该地市下没有区县');
                }
                form.render();
            }
			
			 //动态拼接项目
            function appendMgrThird(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                    }
                    $('#mgrId_third').html(options);
                } else {
                    $('#mgrId_third').html('<option value="">该区县下没有项目</option>');
                }
                form.render();
            }
        //监听第三步中的地市、区县、项目 end
		//监听区县
            form.on('select(cityId)', function (data) {
                var data2 = selectCountyId(data.value);
                appendCounty(data2);
            });
			
			 //监听项目
            /* form.on('select(countyId)', function (data) {
                var data1 = selectMgrInfo(data.value);
                appendMgr(data1);
            }); */
			
			//动态拼接区县
            function appendCounty(data){
                if (data.length != null) {
                    var options = '<option value="">请先选择地市</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                    }
                    $('#countyId').html(options);
                } else {
                    $('#countyId').html('该地市下没有区县');
                }
                form.render();
            }
			
			 //动态拼接项目
            function appendMgr(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                    }
                    $('#mgrId').html(options);
                } else {
                    $('#mgrId').html('<option value="">该区县下没有项目</option>');
                }
                form.render();
            }
			
			//根据城市ID查询区县
            function selectCountyId(cityId) {
                var data;
                var url = '/util/findCountyByCityId?cityId=' + cityId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
			
			//根据城市ID和区县查询项目
            function selectMgrInfo(countyId) {
                var data;
                var url = '/util/findByMgrId?countyId=' + countyId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
		
		//判断项目名称是否重复
			function judgeMgrName(mgrName){
				var url = '/util/getMgrName';
			    $.ajax({
			            url: url,
			            type: 'post',
			            async: false,
			            data: "mgrName="+mgrName,
			            success: function (json) {
			                flagMgr = json.data;
			            }, error: function () {
			                layer.msg('系统异常，请联系管理员处理!');
			            }
			        }
			    );
			}
		//获取复制的项目ID
		 $('#copy').on('click',function(){
		 	copyMgrId = $("#mgrId_third").val();
		 	if(''!=copyMgrId && null!=copyMgrId){
		 		layer.confirm('已复制对应基站', {
					btn: ['确定'] //按钮
				});
		 	}else{
		 		layer.confirm('未选中项目，请选择一个项目', {
					btn: ['确定'] //按钮
				});
		 	}
		 });
		 $('#next').on('click', function () {
			var startTime=$("#startTime").val();
	        var endTime=$("#endTime").val();
	        var everyDayStartTime=$("#everyDayStartTime").val();
	        var everyDayEndTime=$("#everyDayEndTime").val();
	        var realTime=$("input[name='realTime']:checked").val();
	        var isLocal=$("input[name='isLocal']:checked").val();
	        if (isNull(startTime)) {
	          layer.msg("发送开始时间不能为空");
	          return false;
	        }
	        if (isNull(everyDayStartTime)) {
	          layer.msg("每日发送开始时间不能为空");
	          return false;
	        }
	        if (isNull(everyDayEndTime)) {
	          layer.msg("每日发送结束时间不能为空");
	          return false;
	        }
	        if (isNull(realTime)) {
	          layer.msg("发送实时性不能为空");
	          return false;
	        }
	        if (isNull(isLocal)) {
	          layer.msg("号码发送范围不能为空");
	          return false;
	        }
	       	if (""!=endTime && null!=endTime && startTime>=endTime) {
              layer.msg("发送结束时间不能小于等于开始时间");
              return false;
            }
		 	if(step==1){
	            $("#second").css("display","");
	            step = 2;
		 	}else if(step==2){
		 		var content = $("#content").val();
		 		if (isNull(content)) {
		          layer.msg("短信内容不能为空");
		          return false;
		        }
		        $("#next").css("display","none");
		        $("#third").css("display","");
	            $("#upload2").css("display","");
	            $(".layui-table").css("display","");
	            $("h4").css("display","");
		 	}
		 });
		
		$('#upload').on('click', function () {
			var startTime=$("#startTime").val();
	        var endTime=$("#endTime").val();
	        var everyDayStartTime=$("#everyDayStartTime").val();
	        var everyDayEndTime=$("#everyDayEndTime").val();
	        var realTime=$("input[name='realTime']:checked").val();
	        var isLocal=$("input[name='isLocal']:checked").val();
	        var isThreshold = 0;
            $("input:checkbox[name='isThreshold']:checked").each(function () {
                isThreshold += parseInt($(this).val());
            });
            var threshold = $("#threshold").val();
            var cycleThreshold=0;
            var cycle;
            if(isThreshold==2||isThreshold==3){
               	cycle=$("#cycle").val();
                cycleThreshold=$("#cycleThreshold").val();
            }
            var content=$("#content").val();
            var localDate = 0;
            var isProvince = 0;
            if(isLocal==1){
            	isProvince=$("#province").val();
            }else if(isLocal==2){
            	isProvince=1;
            	localDate=$("input[name='localDate']:checked").val();
            }else if(isLocal==0){
             	localDate=$("input[name='localDate']:checked").val();
            }
            var param = {
            		mgrId: mgrId,
                    startTime: startTime,
                    endTime: endTime,   
                    everyDayStartTime: everyDayStartTime,
                    everyDayEndTime: everyDayEndTime,
                    realTime: realTime,
                    isLocal: isLocal,
                    isThreshold:isThreshold,
                    threshold:threshold,
                    cycleThreshold:cycleThreshold,
                    cycle:cycle,
                    newContent:content,
                    localDate: localDate,
                    isProvince: isProvince,
                    effectTime:startTime,
                    reset:"0",
                    flag: "modify"
                };
            var index = layer.load(1, {shade: [0.1,'#fff'] });
            var url='/template2/modify';
            $.ajax({
            		type: 'post',
                    data: param,
                    url: url,
                    async: false,
                    beforeSend: function () {
				        if (isNull(startTime)) {
				          layer.msg("发送开始时间不能为空");
				          return false;
				        }
				        if (isNull(everyDayStartTime)) {
				          layer.msg("每日发送开始时间不能为空");
				          return false;
				        }
				        if (isNull(everyDayEndTime)) {
				          layer.msg("每日发送结束时间不能为空");
				          return false;
				        }
				        if (isNull(realTime)) {
				          layer.msg("发送实时性不能为空");
				          return false;
				        }
				        if (isNull(isLocal)) {
				          layer.msg("号码发送范围不能为空");
				          return false;
				        }
				        if (isNull(content)) {
				          layer.msg("短信内容不能为空");
				          return false;
				        }
				        if (""!=endTime && null!=endTime && startTime>=endTime) {
			              layer.msg("发送结束时间不能小于等于开始时间");
			              return false;
			            }
			            if (everyDayStartTime>=everyDayEndTime) {
			              layer.msg("每日发送结束时间不能小于等于每日开始时间");
			              return false;
			            }
                    },
                    success: function (obj) {
                    	if(obj.code==0 && ''!=copyMgrId && null != copyMgrId){
                    		var url = '/template2/copyStation';
                    		var params = {
                    			copyMgrId:copyMgrId,
                    			mgrId:mgrId
                    		}
                    		$.ajax({
                    			type: 'post',
			                    data: params,
			                    url: url,
			                    async: false,
			                    success: function(obj){
			                    	layer.close(index);
			                    	if(obj.data>0){
			                    		layer.confirm('修改成功，并复制'+obj.data+'个基站', {
						                    btn: ['确定'] //按钮
						                }, function () {
						                    location.href="smsTemplateManage2.html";
						                });
			                    	}else{
			                    		layer.confirm('复制项目失败，如需复制项目，请点击确定留在此页面', {
						                    btn: ['确定','退出'] //按钮
						                }, function () {
						                    layer.close(layer.index);
						                }, function () {
						                    location.href="smsTemplateManage2.html";
						                });
			                    	}
			                    },error: function(){
			                    	layer.close(index);
                    				layer.msg('系统异常，请联系管理员处理!');
			                    }
                    		});
                    	}else if (obj.code==0 && ""!=importStationType && null!=importStationType){
                    	
                    	}else{
                    		layer.close(index);
                    		layer.confirm(obj.msg, {
						        btn: ['确定'] //按钮
						    }, function () {
						        location.href="smsTemplateManage2.html";
						    });
                    	}
                    },
                    error: function(){
                    	layer.close(index);
                    	layer.msg('系统异常，请联系管理员处理!');
                    }
            });    
		});
		 $(".importType").click(function(){
                 	var importType = $("input[name='importType']:checked").val();
                 	if(importType==1){
                 		$(".copyStation").css("display","none");
                 		$(".import").css("display","");
                 		$("#upload2").css("display","");
	                	$("#upload").css("display","none");
                 	}else if(importType==2){
                 		$(".copyStation").css("display","");
                 		$(".import").css("display","none");
                 		$("#upload2").css("display","none");
	                	$("#upload").css("display","");
                 	}
        });
		$(document).ready(function () {
			var url = '/template2/findTemplate';
                var param = {
                    mgrId: mgrId
                };
                $.ajax({
                    type: 'post',
                    async: false,
                    url: url,
                    data: param,
                    beforeSend: function () {
                        loading = layer.load(0, {shade: false});
                    },
                    success: function (json) {
                        layer.close(loading);
                        var data = json.data;
                        console.info(data);
                        if(data.cityId==11){
                        	$("#messageNo").val("10657"+"1101"+data.cityExtId);
                        }else{
                        	$("#messageNo").val("10657"+"1102"+data.cityExtId);
                        }
                        $("#everyDayStartTime").val(data.everyDayStartTime);
                        $("#everyDayEndTime").val(data.everyDayEndTime);
                        $("#cycleThreshold").val(data.cycleThreshold);
                        $("#threshold").val(data.threshold);
                        $("#startTime").val(data.startDate);
                        $("#endTime").val(data.endDate);
                        $("#mgrName").val(data.name);
						$("#belong").val(data.belong);
						$("#content").val(data.content);
						$("input[name='realTime'][value=" + data.realTime + "]").attr("checked", true);
						$("input[name='isLocal'][value=" + data.isLocal + "]").attr("checked", true);
						$("input[name='localDate'][value=" + data.localDate + "]").attr("checked", true);
						$("input[name='province'][value=" + data.isProvince + "]").attr("checked", true);
						$("input[name='cycle'][value=" + data.cycle + "]").attr("checked", true);
						var isThreshold = document.getElementsByName("isThreshold");
						if (data.isThreshold == 1) {
                            isThreshold[0].checked = true;
                        } else if (data.isThreshold == 2) {
                            isThreshold[1].checked = true;
                        } else if (data.isThreshold == 3) {
                            isThreshold[0].checked = true;
                            isThreshold[1].checked = true;
                        }
                        form.render(); 
                        var index = layer.load(1, {
                       		 shade: [0.1,'#fff'] //0.1透明度的白色背景
                    	});
                        table.reload('modelReload', {
		                    method: 'post',
		                    page: {
		                        curr: 1
		                    },
		                    where: {
		                        mgrId: mgrId,
		                        cityId: data.cityId
		                    }
		                });
		                layer.close(index);
					}
				});
				$("#upload").css("display","none");
				$("#upload2").css("display","none");
				$("#second").css("display","none");
				$("#third").css("display","none");
				$(".layui-table").css("display","none");
				$("h4").css("display","none");
				$("#local").show();
				$(".copyStation").css("display","none");
		});
	});
</script>
</head>
<body>
	<!--nav-->
	<div class="layui-html-limit">
		<!--container-->
		<div class="layui-content-body">
			<div class="scroll-box">
				<div class="breadcrumb-box">
					<span class="layui-breadcrumb" lay-separator="|"> <a
						href="javascript:returnIndex2()">首页&nbsp;</a> <a href="">
							&nbsp;短信模板管理&nbsp; </a> <a href="smsTemplateManage2.html">
							&nbsp;短信项目模板配置管理</a> <a href=""> &nbsp;短信项目模板修改&nbsp; </a>
					</span>
				</div>
				<div class="content-box">
					<div class="layui-form layui-form-pane">
						<div class="layui-form-item" id="first">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第一步：项目基本信息配置</label>
							</div>
							<div class="layui-form-item">
		                        <div class="layui-block" pane="">
		                            <label class="layui-form-label">短信通道号</label>
		                            <div class="layui-input-block">
		                                <input type="text"   style="width:auto"
		                                      id="messageNo" autocomplete="off" class="layui-input" disabled>
		                            </div>
		                        </div>
		                    </div>
		                    <div class="layui-form-item">
		                        <div class="layui-block" pane="">
		                            <label class="layui-form-label">归属地</label>
		                            <div class="layui-input-block">
		                                <input type="text"   style="width:auto"
		                                      id="belong" autocomplete="off" class="layui-input" disabled>
		                            </div>
		                        </div>
		                    </div>
		                    <div class="layui-form-item">
		                        <div class="layui-block" pane="">
		                            <label class="layui-form-label">项目名称</label>
		                            <div class="layui-input-block">
		                                <input type="text"   style="width:auto"
		                                      id="mgrName" autocomplete="off" class="layui-input" disabled>
		                            </div>
		                        </div>
		                    </div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label" style="width: auto">发送起止时间</label>
									<div class="layui-input-inline">
										<input type="text" name="date" id="startTime"
											autocomplete="off" class="layui-input" placeholder="请选择"
											lay-verify="required">
									</div>
									<div class="layui-form-mid">-</div>
									<div class="layui-input-inline">
										<input type="text" name="date" id="endTime" autocomplete="off"
											class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-inline">(结束时间可以为空,代表永久有效)</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block">
									<label class="layui-form-label" style="width:auto">每日发送时间段</label>
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayStartTime"
											autocomplete="off" class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-form-mid">-</div>
									<div class="layui-input-inline">
										<input type="text" name="date" id="everyDayEndTime"
											autocomplete="off" class="layui-input" placeholder="请选择">
									</div>
									<div class="layui-inline">(若想在发送起止时间内连续发送，请将每日发送时间段置为00:00:00至23:59:59)</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label">发送实时性</label>
									<div class="layui-input-block">
										<input type="radio" name="realTime" value="0" title="立即发送">
										<input type="radio" name="realTime" value="5" title="延迟5分钟发送">
										<input type="radio" name="realTime" value="10" title="延迟10分钟发送">
										<input type="radio" name="realTime" value="20" title="延迟20分钟发送"
											checked="">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">号码发送范围</label>
									<div class="layui-input-block">
										<input type="radio" name="isLocal" value="0" title="本地"
											lay-filter="localDate1" checked="checked"> <input type="radio"
											name="isLocal" value="1" title="外地" lay-filter="localDate1">
										<input type="radio" name="isLocal" value="2" title="本地+外地"
											lay-filter="localDate1">
									</div>
								</div>
							</div>
							<div class="layui-form-item hiden" id="local"
								style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">本地号码保存时间</label>
									<div class="layui-input-block">
										<input type="radio" name="localDate" value="7" title="7天"
											checked=""> <input type="radio" name="localDate"
											value="15" title="15天"> <input type="radio"
											name="localDate" value="30" title="30天"> <input
											type="radio" name="localDate" value="90" title="90天">
										<input type="radio" name="localDate" value="180" title="180天">
									</div>
								</div>
							</div>
							<div class="layui-form-item hiden" id="province"
								style="display: none">
								<div class="layui-block" pane="">
									<label class="layui-form-label" style="width: auto">发送范围选择</label>
									<div class="layui-input-block">
										<input type="radio" name="province" value="0" title="省内" checked="checked"> 
										<input type="radio" name="province" value="1" title="全部"> 
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label" style="width: auto">短信发送量阀值设置</label>
								<div class="layui-inline">
									<div class="layui-form-item">
										<div class="layui-inline">
											<input type="checkbox" name="isThreshold" title="短信发送总量"
												value="1">
										</div>
									</div>
									<div class="layui-form-item">
										<div class="layui-inline" pane="">
											<label class="layui-form-label" style="width: auto">短信发送总条数:</label>
											<div class="layui-input-inline" style="width: auto">
												<input type="text" id="threshold" placeholder="请输入"
													autocomplete="off" class="layui-input" value="0">
											</div>
										</div>
										<div class="layui-inline">条</div>
									</div>
									<div class="layui-form-item">
										<input type="checkbox" name="isThreshold" title="周期短信发送量"
											value="2">
									</div>
									<div class="layui-inline" pane="">
										<input type="radio" name="cycle" value="1" title="按年" checked>
										<input type="radio" name="cycle" value="2" title="按月">
										<input type="radio" name="cycle" value="3" title="按周">
										<input type="radio" name="cycle" value="4" title="按日">
	
	
									</div>
									<div class="layui-form-item">
										<h4 class="tips-h4">
											<i class="iconfont icon-xinxi"></i>
											周发送量不是当天的起，是该周周一开始计算，月发送量就是从当月一号开始算。
										</h4>
									</div>
									<div class="layui-form-item">
										<div class="layui-form-item">
											<div class="layui-inline" pane="">
												<label class="layui-form-label">短信发送量:</label>
												<div class="layui-input-inline" style="width: 100px;">
													<input type="text" placeholder="请输入" id="cycleThreshold"
														autocomplete="off" class="layui-input" value="0">
												</div>
											</div>
											<div class="layui-inline">条</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						
						<div class="layui-form-item layui-form-text" id="second">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第二步：项目发送内容配置</label>
							</div>
							<br> <label class="layui-form-label">短信内容</label>
							<div class="layui-input-block">
								<textarea class="layui-textarea" id="content"
									lay-verify="required"></textarea>
							</div>
						</div>
						<div class="layui-form-item" id="third">
							<div class="layui-inline">
								<label class="layui-btn layui-btn-lg layui-btn-normal" style="cursor:auto;">第三步：项目基站信息导入</label>
							</div>
							<div class="layui-form-item importType">
					                    	<label class="layui-form-label" style="width:120px">导入方法</label>
					                        <div class="layui-input-block">
					                        	<input class="radioItem" lay-filter="gis" type="radio" name="importType" title="导入基站" onclick="ChooseRadio(this)" value="1" checked="checked">
					                            <input class="radioItem" lay-filter="gis" type="radio" name="importType" title="复制其他项目基站" onclick="ChooseRadio(this)" value="2">
					                        </div>
					        </div>
					        <div class="layui-form-item copyStation">
								<div class="layui-inline ">
									<label class="layui-form-label">地市</label>
									<div class="layui-input-block" style="width:150px">
										<select name="cityId_third" lay-filter="cityId_third" id="cityId_third">
											<option value="">请选择</option>
											<option value="11">苏州</option>
											<option value="12">淮安</option>
											<option value="13">宿迁</option>
											<option value="14">南京</option>
											<option value="15">连云港</option>
											<option value="16">徐州</option>
											<option value="17">常州</option>
											<option value="18">镇江</option>
											<option value="19">无锡</option>
											<option value="20">南通</option>
											<option value="21">泰州</option>
											<option value="22">盐城</option>
											<option value="23">扬州</option>
											<option value="25">省级</option>
										</select>
									</div>
								</div>
								<div class="layui-inline countyId">
		                            <label class="layui-form-label">区县</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <select name="countyId_third" lay-filter="countyId_third" id="countyId_third">
		                                    <option value="">全部</option>
		                                </select>
		                            </div>
		                        </div>
		                        <div class="layui-inline mgrId">
		                            <label class="layui-form-label">项目名称</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <select name="mgrId_third" lay-filter="mgrId_third" id="mgrId_third">
		                                    <option value="">请选择</option>
		                                </select>
		                            </div>
		                        </div>
		                        <div class="layui-inline">
		                            <div class="layui-block">
				                            <button class="layui-btn layui-btn-normal" id="copy">复制</button>
				                            <label id="copyMgrId" style="visibility:hidden;">123</label>
				                	</div>
		                        </div>
		                        <!-- <div class="layui-inline mgrName">
		                            <label class="layui-form-label">项目简称</label>
		                            <div class="layui-input-block" style="width:150px">
		                                <input type="text" name="mgrName_third" id="mgrName_third" lay-verify="required" placeholder="请输入"
		                                            autocomplete="off" class="layui-input" />
		                            </div>
		                        </div> -->
							</div>
							<div class="layui-form-item import">
        						<label class="layui-form-label" style="width: 120px;">基站信息</label>
                                <div class="layui-inline">
                                    	<input type="text" name="importText" id="importText" 
	                                            autocomplete="off" class="layui-input" disabled/>
                                </div>
                                <div class="layui-inline">
                                    	<button type="button" class="layui-btn importStation" id="importCover"><i class="layui-icon"></i>覆盖导入</button>
                                </div>
                                <div class="layui-inline">
                                    	<button type="button" class="layui-btn importStation" id="importAdd"><i class="layui-icon"></i>追加导入</button>
                                </div>
        					</div>
							<!-- <br>
							<div class="layui-inline">
								<button type="button" class="layui-btn" id="import">
									<i class="layui-icon"></i>区域基站导入
								</button>
							</div> -->
							<!-- <br class="layui-form-item"> <span><a
								href="/smsBaseStation/apidownload"><u>基站导入帮助手册</u></a></span></br> <span><a
								href="/smsBaseStation/modeldownload"><u>基站导入模板下载</u></a></span> -->
						</div>
						<div class="layui-table">
		                	<table id="table" lay-filter="tableElement"></table>
		           	 	</div>
						<div class="layui-block">
	                            <button class="layui-btn layui-btn-normal" id="next">下一步</button>
	                	</div>
						<div class="layui-form-item">
							<button class="layui-btn" id="upload">提交并开启</button>
						</div>
						<div class="layui-form-item">
							<button class="layui-btn" id="upload2">提交并开启</button>
						</div>
					</div>
					<h4 class="tips-h4">
						<i class="iconfont icon-xinxi"></i>
						地市短信项目管理员设置或者修改模板属性提交后短信通知省公司管理员审核，审核通过后设置或者修改属性才能生效
					</h4>
				</div>
			</div>
		</div>
	</div>
</body>
</html>